#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__

#include "Thread.hpp"
#include "TaskQue.hpp"

#include <queue>
#include <memory>

using std::unique_ptr;
using std::vector;

namespace cdm{

class ThreadPool{

    friend class MyThread;
public:
    ThreadPool(size_t ,size_t);
    ~ThreadPool();

    void start();
    void stop();

    void addTask(Task && cb);

private:
    void doTask();

private:
    vector<unique_ptr<Thread>>  _threadQue;
    size_t                      _threadSize;
    size_t                      _taskSize;
    TaskQue                     _taskQue;
    bool                        _isExit;
};



}//end of namespace

#endif


